6 struct MapRenderView: View {
8 @Binding var content: String
9 @Binding var evolution: StageType
12 Stage.stages(evolution)
15 @State var parsedMap: ParsedMap = ParsedMap.empty
17 let mapSize = CGSize(width: 1300.0, height: 1000.0)
19 let lineWidth = CGFloat(0.5)
20 let vertexSize = CGSize(width: 25.0, height: 25.0)
21 let padding = CGFloat(30.0)
24 ZStack(alignment: .topLeading) {
29 x: -padding, y: -padding, width: mapSize.width + padding * 2,
30 height: mapSize.height + padding * 4))
33 MapStages(mapSize: mapSize, lineWidth: lineWidth, stages: parsedMap.stages)
35 mapSize: mapSize, lineWidth: lineWidth, evolution: stage, stages: parsedMap.stages)
37 mapSize: mapSize, lineWidth: lineWidth, vertexSize: vertexSize, edges: parsedMap.edges)
38 MapBlockers(mapSize: mapSize, vertexSize: vertexSize, blockers: parsedMap.blockers)
39 MapVertices(mapSize: mapSize, vertexSize: vertexSize, vertices: parsedMap.vertices)
41 mapSize: mapSize, lineWidth: lineWidth, vertexSize: vertexSize,
42 opportunities: parsedMap.opportunities)
44 mapSize: mapSize, lineWidth: lineWidth, notes: parsedMap.notes)
47 height: mapSize.height + 2 * padding, alignment: .topLeading
49 self.parsedMap = Map.parse(content: content)
50 }.padding(padding).onChange(of: content) { newState in
51 self.parsedMap = Map.parse(content: newState)
56 struct MapRenderView_Previews: PreviewProvider {
57 static var previews: some View {
59 content: Binding.constant(""), evolution: Binding.constant(StageType.general)
61 \.managedObjectContext, PersistenceController.preview.container.viewContext)